package gameos.menu.namemap;

import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent;

import gameos.core.Asset;
import gameos.core.GameOS;
import gameos.core.IScreen;
import gameos.core.IVisible;
import gameos.menu.IEntityMenu;
import gameos.menu.selectmap.BackBut;

public class NameMapUi extends IEntityMenu implements IVisible{

	public int id;
	
	public NameMapUi (GameOS game, IScreen screen) {
		super(game, screen);
		// TODO Auto-generated constructor stub
	}
	
	Table container;	
	Image hanoi, halong, saigon,japan, roma,aicap,hoangsa;
	@Override
	public void start () {
		// TODO Auto-generated method stub
		container = game.stageHelper.createTable(0, 0, game.X(838), game.Y(490));
		container.addActor(game.stageHelper.createImage(Asset.blackRegion, 0, 0, game.X(839), game.Y(490)));		
		hanoi = game.stageHelper.createImage(Asset.stringHanoiRegion, game.X(318), game.Y(207), game.X(202), game.Y(75));
		halong = game.stageHelper.createImage(Asset.stringHalongRegion, game.X(318), game.Y(207), game.X(202), game.Y(75));
		saigon = game.stageHelper.createImage(Asset.stringSaigonRegion, game.X(318), game.Y(207), game.X(202), game.Y(75));
		japan = game.stageHelper.createImage(Asset.stringJapanRegion, game.X(318), game.Y(207), game.X(202), game.Y(75));
		roma = game.stageHelper.createImage(Asset.stringRomaRegion, game.X(318), game.Y(207), game.X(202), game.Y(75));
		aicap = game.stageHelper.createImage(Asset.stringAicapRegion, game.X(318), game.Y(207), game.X(202), game.Y(75));
		hoangsa = game.stageHelper.createImage(Asset.stringDaoRegion, game.X(318), game.Y(207), game.X(202), game.Y(75));

		container.addActor(hanoi);
		container.addActor(halong);
		container.addActor(saigon);
		container.addActor(japan);
		container.addActor(roma);
		container.addActor(aicap);
		container.addActor(hoangsa);
		game.stage.addActor(container);				
		hide();
	}

	@Override
	public void stop () {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void draw () {
		// TODO Auto-generated method stub
		
	}
	int tick;
	@Override
	public void update (int delayTime) {
		// TODO Auto-generated method stub
		if(container.isVisible())
		{
			if(Asset.manager.update()){
				if(game.gameScreen.stage == 1)
					Asset.loadedHanoi(game,game.screenInfo);
				else if(game.gameScreen.stage == 2)
					Asset.loadedHalong(game, game.screenInfo);
				else if(game.gameScreen.stage == 3)
					Asset.loadedSaigon(game, game.screenInfo);
				else if(game.gameScreen.stage == 4)
					Asset.loadedJapan(game, game.screenInfo);
				else if(game.gameScreen.stage == 5)
					Asset.loadedRome(game, game.screenInfo);
				else if(game.gameScreen.stage == 6)
					Asset.loadedAicap(game, game.screenInfo);
				else if(game.gameScreen.stage == 7)
					Asset.loadedDao(game, game.screenInfo);
				game.menuScreen.stop();
				game.gameScreen.start();
			}
		}
	}

	@Override
	public void hide () {
		// TODO Auto-generated method stub
		container.setVisible(false);
	}

	public void set(int id)
	{
		this.id = id;
		halong.setVisible(false);
		hanoi.setVisible(false);
		saigon.setVisible(false);
		japan.setVisible(false);
		roma.setVisible(false);
		aicap.setVisible(false);
		hoangsa.setVisible(false);
		if(id == 1)
		{
			hanoi.setVisible(true);
		}
		else if(id == 2)
		{			
			halong.setVisible(true);
		}
		else if(id==3)
		{
			saigon.setVisible(true);
		}
		else if(id == 4)
		{
			japan.setVisible(true);
		}
		else if(id == 5)
		{
			roma.setVisible(true);
		}
		else if(id == 6)
		{
			aicap.setVisible(true);
		}
		else if(id == 7)
		{
			hoangsa.setVisible(true);
		}
	}
	
	@Override
	public void show () {
		// TODO Auto-generated method stub
		container.setVisible(true);
	}

}
